#include<cstdio>
#include<cstring>
#include<algorithm>
template<class T>void read(T &x)
{
	x=0;int f=0;char ch=getchar();
	while(ch<'0'||ch>'9') { f|=(ch=='-'); ch=getchar(); }
	while(ch<='9'&&ch>='0') { x=(x<<1)+(x<<3)+(ch^48); ch=getchar(); }
	x = f ? -x : x;
	return ;
}

int F[330][330];
int J[330][330];
int l[220];
int sum[220];
int n;

int D(int i,int j) { return sum[j]-sum[i-1]; }

int main()
{
	read(n);
	for(int i=1;i<=n;++i)
	{
		read(l[i]);
		l[i+n]=l[i];
	}
	for(int i=1;i<=2*n;++i)
		sum[i] = sum[i-1] + l[i];

	memset(J,0x7f7f7f,sizeof(J));
	for(int i=1;i<=2*n;++i)
		J[i][i]=0;
	
	for(int r=2;r<=n;r++)
	{
		for(int i=1;i<=2*n-r+1;i++)
		{
			int j=i+r-1;
			for(int k=i;k<j;k++)
			{
				F[i][j] = std::max(F[i][j],F[i][k]+F[k+1][j]+D(i,j));
				J[i][j] = std::min(J[i][j],J[i][k]+J[k+1][j]+D(i,j));
			}
		}
	}

	int mi=0x7f7f7f,mx=-1;
	for(int i=1;i<=n;++i)
	{
		mx = std::max(mx,F[i][i+n-1]);
		mi = std::min(mi,J[i][i+n-1]);
	}
	printf("%d\n%d",mi,mx);

	return 0;
}
